function t(t, e, a) {
    return e in t ? Object.defineProperty(t, e, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = a, t;
}

var e, a = require("../../0E8B0BC42FB173BF68ED63C34BB4DCA6.js"), n = require("../../30A2BE152FB173BF56C4D61233F4DCA6.js"), r = require("../../A7DBB9B62FB173BFC1BDD1B19505DCA6.js"), i = require("../../243038142FB173BF425650139115DCA6.js");

wx.setStorageSync("all", i), wx.setStorageSync("num", 100);

var o = wx.createInnerAudioContext(), s = wx.createInnerAudioContext(), u = wx.createInnerAudioContext(), l = getApp(), c = null;

Page({
    data: (e = {
        isx: /iphone10|iphone x/i.test(wx.getSystemInfoSync().model),
        isAndroid: /android/i.test(wx.getSystemInfoSync().system),
        size: {
            w: 599,
            h: 600
        },
        musicflg: !0,
        fastJuedin: !1,
        repeat: !1,
        xiaojuedingArr: i.sort(function(t, e) {
            return Math.random() > .5 ? -1 : 1;
        }),
        selectedTxt: "？",
        share: !0
    }, t(e, "selectedTxt", ""), t(e, "animationData", {}), t(e, "zhuanflg", !1), t(e, "fastTime", 7600), 
    t(e, "slowTime", 3900), t(e, "probability", !1), t(e, "musicflg", !1), t(e, "fastJuedin", !1), 
    t(e, "repeat", !1), t(e, "size", {
        w: 700,
        h: 700
    }), t(e, "top", 1280), t(e, "turnNum", 16), t(e, "currentPages", 1), e),
    onLoad: function(t) {
        this.setData({
            currentPages: getCurrentPages().length
        });
    },
    onShow: function(t) {
        var e = this.data.xiaojuedingArr;
        o.src = "/mp3/start.mp3", s.src = "/mp3/mid.mp3", u.src = "/mp3/stop.mp3";
        var a = e[0], n = 1 / a.awards.length;
        this.setData({
            awardsConfig: a,
            turnNum: n,
            selectedTxt: a.awards[0].name,
            musicflg: !l.globalData.musicflg,
            fastJuedin: !!l.globalData.juedin,
            repeat: !!l.globalData.repeat
        });
    },
    onShareAppMessage: function(t) {
        return {
            title: n(a.SHARE.title)[0],
            path: "/pages/roulette/index",
            imageUrl: "/assets/" + n(a.SHARE.image)[0]
        };
    },
    onHide: function() {
        this.onBreakRoulette();
    },
    onUnload: function() {
        this.onBreakRoulette();
    },
    onBreakRoulette: function() {
        console.log("onBreakRoulette..."), o.stop(), s.stop(), u.stop();
    },
    calculateTop: function() {
        var t = this;
        this.createSelectorQuery().selectAll(".gb-wheel-icontent").boundingClientRect(function(e) {
            var a = e[0].top, n = e[0].dataset.index;
            e.forEach(function(t, e) {
                t.top < a && (a = t.top, n = t.dataset.index);
            }), t.setData({
                selectedTxt: t.data.awardsConfig.awards[n].name
            });
        }).exec();
    },
    _zhuan: function() {
        console.log("start...");
        var t = this, e = t.data.awardsConfig, a = Math.random() * e.awards.length >>> 0;
        t.data.repeat ? a = t._queryRepeat(a) : (wx.removeStorageSync("repeatArr"), console.log("是否开启了概率？？？", t.data.probability), 
        t.data.probability && (a = t._openProbability()));
        var n = t.data.fastJuedin ? t.data.slowTime : t.data.fastTime;
        t.data.musicflg && (t.data.fastJuedin ? s.play() : o.play()), l.runDegs = l.runDegs || 0, 
        l.runDegs = l.runDegs + (360 - l.runDegs % 360) + (2160 - a * (360 / e.awards.length));
        var r = wx.createAnimation({
            duration: n,
            timingFunction: "ease"
        });
        t.animation = r, r.rotate(l.runDegs).step(), 0 == a && (l.runDegs = 0), t.setData({
            animationData: r.export(),
            block1: "none",
            block2: "block",
            block3: "none",
            zhuanflg: !0,
            punishType: ""
        }), c = setInterval(function() {
            t.calculateTop();
        }, 100), setTimeout(function() {
            for (var n in e.awards) e.awards[n].opacity = n != a ? "0.3" : "1";
            t.data.musicflg && u.play(), c && (clearInterval(c), c = null), t.setData({
                animationData: {},
                zhuanflg: !1
            });
        }, n), setTimeout(function() {
            t.calculateTop();
            var e = t.data.selectedTxt, a = "";
            /真心话/g.test(e) ? a = "truth" : /大冒险/g.test(e) && (a = "risk"), console.log("punishType:", a), 
            t.setData({
                isEnd: !0,
                punishType: a
            });
        }, n + 100);
    },
    _openProbability: function() {
        var t = this.data.awardsConfig.awards, e = [];
        for (var a in t) if (0 != t[a].probability) for (var n = 0; n < t[a].probability; n++) e.push(a);
        return e[Math.floor(Math.random() * e.length)];
    },
    _queryRepeat: function(t) {
        var e = !0, a = wx.getStorageSync("repeatArr"), n = [], r = this.data.awardsConfig;
        if (this.isNull(a)) return n.push(t), wx.setStorageSync("repeatArr", n), t;
        var i = r.awards.length;
        t = Math.random() * i >>> 0;
        for (var o in a) if (t == a[o]) return e = !1, a.length == i ? (wx.removeStorageSync("repeatArr"), 
        n.push(t), wx.setStorageSync("repeatArr", n), t) : this._queryRepeat();
        return e ? (a.push(t), wx.setStorageSync("repeatArr", a), t) : void 0;
    },
    punish: function(t) {
        wx.navigateTo({
            url: "/pages/punishment/index?punishType=" + t.target.id
        });
    },
    back: function() {
        r.navigateBack();
    }
});